# -- coding: utf-8 --

import os

# def copy(sourcePath, targetPath):
#     sourceFd = os.open(sourcePath, os.O_RDONLY)   #只读方式打开
#     targetFd = os.open(targetPath, os.O_WRONLY | os.O_CREAT)   #以只写方式打开，并创建一个新文件
#
#     while (True):
#         binary = os.read(sourceFd,1024)      # read赋值 一个是要读的文件，另一个是数量
#         if len(binary) == 0: # 不要忘记判断这个文件到哪里结束，不然会一直运行下去，淦
#             return
#         os.write(targetFd,binary)    # write赋值  一个是要写入的文件，另一个要是写入的数据
#
# copy('../pyIterable/test.txt','123.txt')

# cwd = os.getcwd()
# print(cwd)
# print(os.listdir())

# print(os.path.basename('D:\\pycharm\\sms\\pythonOsModel\\123.txt'))
#
# test_path = 'D:\\pycharm\\sms\\pythonOsModel\\123.txt'
#
# print(os.sep)
#
# print(os.path.join('D:acv','dfd','dfd'))
# print(os.path.getsize(test_path))
# test_path = 'D:\\pycharm\\sms\\pythonOsModel\\123.txt'
# if os.path.exists(test_path) == True:
#     print('有啊')
# else:
#     print('没')
dir = 'test'
# os.chdir(dir)
print(os.getcwd())
print(os.listdir(dir))

def listdir(dir):
    entries = os.listdir(dir)
    for entry in entries:
        path = os.path.join(dir,entry)
        print(path)
        if os.path.isdir(path):
            listdir(path)

listdir('test')